//
//  UIApplication+LCAddition.m
//  UI122501
//
//  Created by admin on 2017/12/26.
//  Copyright © 2016年 LC. All rights reserved.
//

#import "UIApplication+LCAddition.h"

@implementation UIApplication (LCAddition)

+(void)lc_optionsIconBadgeNumber:(NSInteger)iconBadgeNumber{
    
    
    UIApplication *application= [UIApplication sharedApplication];
    application.applicationIconBadgeNumber = iconBadgeNumber;
    
    CGFloat systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
    
    if (systemVersion >= 8.0 && systemVersion < 10.0) {  //大于8.0以后,才需要注册
        //8.0可用,10.0废弃
        
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:nil];
        [application registerUserNotificationSettings:settings];
#pragma clang diagnostic pop
    }else{
//        UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
//        
//        [center requestAuthorizationWithOptions:UNAuthorizationOptionBadge | UNAuthorizationOptionAlert completionHandler:^(BOOL granted, NSError * _Nullable error) {
//            //            NSLog(@"granted = %d",granted );
//        }];
    }
    
}

@end
